package com.goktech.olala.core.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.goktech.olala.core.service.ICommentService;
import com.goktech.olala.server.dao.comment.CommentMapper;
import com.goktech.olala.server.pojo.comment.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("commentService")
public class CommentServiceImpl implements ICommentService {
    @Autowired
    CommentMapper commentMapper;

    //查询所有评论
    @Override
    public PageInfo<Comment> queryAllComment(int pageIndex, int pageSize, Comment comment) throws Exception {
        PageHelper.startPage(pageIndex, pageSize);
        List<Comment> infoList = commentMapper.selectAllByExample(comment);
        PageInfo<Comment> pageInfo = new PageInfo(infoList);
        return pageInfo;
    }

    //删除对应评论
    @Override
    public int removeCommentById(Long commentId) {
        return commentMapper.deleteByPrimaryKey(commentId);
    }

    //查询意见反馈
    @Override
    public PageInfo<Comment> queryAdvices(int pageIndex, int pageSize, Comment comment) throws Exception {
        PageHelper.startPage(pageIndex, pageSize);
        List<Comment> infoList = commentMapper.selectByExample(comment);
        PageInfo<Comment> pageInfo = new PageInfo(infoList);
        return pageInfo;
    }

    @Override
    public List<Comment> SelectDetailAndCommentById(String customerId) throws Exception {
        return commentMapper.SelectDetailAndCommentById(customerId);
    }
}
